Unassigned variable issue

Hi All,

This is probably something very obvious but I am unable to see the wood for the trees.

I have a number functions to display and export a VCRI view which I wrote for a previous project and works perfectly. I'm trying to reuse these functions in another project and cannot understand why I am receiveing the unassigned variable error for the DBE. The listView DBE has been populated and "set" successfully. The test select, deselect and activate functions all work ok, but when the export matrix callback is called the DB definitions are being lost!

Any help is greatly appreciated.

Thanks

Mark
 

string empty_list[] = {}
 
DB TestMatrixDB                 = create ("Test Matrix Selection",styleFixed|styleCentered|styleFloating)
DBE CurrentTestsDBE             = listView(TestMatrixDB,0,200,15,empty_list)
DBE  matrixFile                 = label (TestMatrixDB, "Target Document")
DBE ms                          = fileName TestMatrixDB
set(ms,  "*.xls", "Excel Document") 
 
void exportMatrix(DB db)
{
 
   string seltest = get(CurrentTestsDBE)
   string file = get(ms)
   Item itemRef
   Module m
   for itemRef in (current Folder)do
   {
           if ((name(itemRef)) == seltest)
           {
                        
                        m = read((name(itemRef)),true)
                        load view "VCRI"
       }      
   }                  
    //Then create buffer for output file
}
 
void getMatrix()
{
        apply (TestMatrixDB,"Export",exportMatrix)
        realize (TestMatrixDB)
        Item itemRef
        ModuleProperties mp
        Module m
                
        for itemRef in (current Folder) do
        { 
                
                if (type(itemRef) == "Formal") 
                {    
                        ModuleVersion mv = moduleVersion(module(name(itemRef)))
                        string res = getProperties(mv, mp)
                        if (res != "")
                        {
                                infoBox("Error reading properties: " res)
                                halt
                        }
                        if ((name(itemRef)) != "Test Module template")
                        {
                                insert (CurrentTestsDBE,0,(name(itemRef)))      
                        }                            
                }
        }                   
        set(CurrentTestsDBE,testSelect,testDeselect,testActivate)       
        insertColumn(CurrentTestsDBE,0,"Current Tests",200,iconNone)
}
 
getMatrix()

mwilliamson - Mon Nov 02 05:24:25 EST 2009

Re: Unassigned variable issue
Peter_Albert - Mon Nov 02 07:46:04 EST 2009

You only 'realize' the dialogue box, but you also have to 'show' it. From the DXL help (realize): "Creates and displays the dialog box without suspending execution of the DXL program. The dialog box only becomes active when a show function is called, either for this dialog box or another."

Adding "show TestMatrixDB" to the end of your script makes it work, but you must keep in mind that DXL execution ends after that line. No code should appear after a show as it would never be executed.

Regards,

Peter

Re: Unassigned variable issue
mwilliamson - Mon Nov 02 08:46:54 EST 2009

Peter_Albert - Mon Nov 02 07:46:04 EST 2009
You only 'realize' the dialogue box, but you also have to 'show' it. From the DXL help (realize): "Creates and displays the dialog box without suspending execution of the DXL program. The dialog box only becomes active when a show function is called, either for this dialog box or another."

Adding "show TestMatrixDB" to the end of your script makes it work, but you must keep in mind that DXL execution ends after that line. No code should appear after a show as it would never be executed.

Regards,

Peter

Hi Peter,

I am kicking myself as I have done this hundreds of times before. Sometimes the the more obvious the silly error the harder it is to find.

I think that this is the consequence of rationalisng a large DXL script into smaller more managemable and reusable functions.

Thank you very much for your prompt response.

Regards

Mark